Leaflet 地图开发–Leaflet Map Event objects—事件对象

Leaflet 地图开发–Leaflet Map Event objects—事件对象

Whenever a class inheriting from Evented fires an event, a listener function will be called with an event argument, which is a plain object containing information about the event. For example:

每当从Evented继承的类触发事件时,将使用事件参数调用侦听器函数,该参数是包含事件信息的纯对象。例如:

map.on('click', function(ev) {
    alert(ev.latlng); // ev is an event object (MouseEvent in this case)
});

The information available depends on the event type:

可用信息取决于事件类型:

Event

The base event object. All other event objects contain these properties too.
基本事件对象。所有其他事件对象也包含这些属性。
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

KeyboardEvent

Property Type Description
originalEvent DOMEvent The original DOM KeyboardEvent that triggered this Leaflet event.

触发此传单事件的原始DOM KeyboardEvent。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

MouseEvent

Property Type Description
latlng LatLng The geographical point where the mouse event occurred.

发生鼠标事件的地理点。

layerPoint Point Pixel coordinates of the point where the mouse event occurred relative to the map layer.

发生鼠标事件的点相对于地图层的像素坐标。

containerPoint Point Pixel coordinates of the point where the mouse event occurred relative to the map сontainer.

鼠标事件发生点相对于地图容器的像素坐标。

originalEvent DOMEvent The original DOM MouseEvent or DOM TouchEvent that triggered this Leaflet event.

触发此传单事件的原始DOM MouseEvent或DOM TouchEvent。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

LocationEvent

Property Type Description
latlng LatLng Detected geographical location of the user.

检测到用户的地理位置。

bounds LatLngBounds Geographical bounds of the area user is located in (with respect to the accuracy of location).

用户所在区域的地理边界(相对于位置的准确性)。

accuracy Number Accuracy of location in meters.

位置精度(单位:米)。

altitude Number Height of the position above the WGS84 ellipsoid in meters.

WGS84椭球上方位置的高度,单位为米。

altitudeAccuracy Number Accuracy of altitude in meters.

高度精度(米)。

heading Number The direction of travel in degrees counting clockwise from true North.

从正北开始顺时针计数的行进方向(以度为单位)。

speed Number Current velocity in meters per second.

流速(米/秒)。

timestamp Number The time when the position was acquired.

获取位置的时间。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

ErrorEvent

Property Type Description
message String Error message.

错误消息。

code Number Error code (if applicable).

错误代码(如果适用)。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

LayerEvent

Property Type Description
layer Layer The layer that was added or removed.

添加或删除的图层。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

LayersControlEvent

Property Type Description
layer Layer The layer that was added or removed.

添加或删除的图层。

name String The name of the layer that was added or removed.

添加或删除的图层的名称。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

TileEvent

Property Type Description
tile HTMLElement The tile element (image).

平铺元素(图像)。

coords Point Point object with the tile’s xy, and z (zoom level) coordinates.

使用平铺的x、y和z(缩放级别)坐标指向对象。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

TileErrorEvent

Property Type Description
tile HTMLElement The tile element (image).

平铺元素(图像)。

coords Point Point object with the tile’s xy, and z (zoom level) coordinates.

使用平铺的x、y和z(缩放级别)坐标指向对象。

error * Error passed to the tile’s done() callback.

传递给磁贴的done()回调的错误。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

ResizeEvent

Property Type Description
oldSize Point The old size before resize event.

调整大小事件之前的旧大小。

newSize Point The new size after the resize event.

调整大小事件后的新大小。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

GeoJSONEvent

Property Type Description
layer Layer The layer for the GeoJSON feature that is being added to the map.

正在添加到地图中的GeoJSON功能的图层。

properties Object GeoJSON properties of the feature.

功能的GeoJSON属性。

geometryType String GeoJSON geometry type of the feature.

功能的GeoJSON几何类型。

id String GeoJSON ID of the feature (if present).

功能的GeoJSON ID(如果存在)。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

PopupEvent

Property Type Description
popup Popup The popup that was opened or closed.

打开或关闭的弹出窗口

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

TooltipEvent

Property Type Description
tooltip Tooltip The tooltip that was opened or closed.

打开或关闭的工具提示。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

DragEndEvent

Property Type Description
distance Number The distance in pixels the draggable element was moved by.

可拖动元素移动的距离(以像素为单位)。

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

ZoomAnimEvent

Property Type Description
center LatLng The current center of the map

地图的当前中心

zoom Number The current zoom level of the map

地图的当前缩放级别

noUpdate Boolean Whether layers should update their contents due to this event

层是否应因此事件更新其内容

从事件继承的属性

Property Type Description
type String The event type (e.g. 'click').

事件类型(例如“单击”)。

target Object The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.

引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。

sourceTarget Object The object that originally fired the event. For non-propagated events, this will be the same as the target.

最初激发事件的对象。对于未传播的事件,这将与目标相同。

propagatedFrom Object For propagated events, the last object that propagated the event to its event parent.

对于传播的事件,将事件传播到其事件父级的最后一个对象。

layer Object Deprecated. The same as propagatedFrom.

已弃用。与propagatedFrom相同。

0 0 投票数
文章评分
订阅评论
提醒
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x